import 'package:flutter/material.dart';

/// UI组件库阴影令牌
/// Material Design 3 高程系统
class UIShadows {
  // 高程级别阴影
  static const List<BoxShadow> elevation0 = [];

  static const List<BoxShadow> elevation1 = [
    BoxShadow(
      color: Color(0x0F000000),
      offset: Offset(0, 1),
      blurRadius: 3,
      spreadRadius: 1,
    ),
    BoxShadow(
      color: Color(0x1E000000),
      offset: Offset(0, 1),
      blurRadius: 2,
      spreadRadius: 0,
    ),
  ];

  static const List<BoxShadow> elevation2 = [
    BoxShadow(
      color: Color(0x0F000000),
      offset: Offset(0, 2),
      blurRadius: 6,
      spreadRadius: 2,
    ),
    BoxShadow(
      color: Color(0x1E000000),
      offset: Offset(0, 1),
      blurRadius: 2,
      spreadRadius: 0,
    ),
  ];

  static const List<BoxShadow> elevation3 = [
    BoxShadow(
      color: Color(0x0F000000),
      offset: Offset(0, 4),
      blurRadius: 8,
      spreadRadius: 3,
    ),
    BoxShadow(
      color: Color(0x1E000000),
      offset: Offset(0, 1),
      blurRadius: 3,
      spreadRadius: 0,
    ),
  ];

  static const List<BoxShadow> elevation4 = [
    BoxShadow(
      color: Color(0x0F000000),
      offset: Offset(0, 6),
      blurRadius: 10,
      spreadRadius: 4,
    ),
    BoxShadow(
      color: Color(0x1E000000),
      offset: Offset(0, 2),
      blurRadius: 3,
      spreadRadius: 0,
    ),
  ];

  static const List<BoxShadow> elevation5 = [
    BoxShadow(
      color: Color(0x0F000000),
      offset: Offset(0, 8),
      blurRadius: 12,
      spreadRadius: 6,
    ),
    BoxShadow(
      color: Color(0x1E000000),
      offset: Offset(0, 4),
      blurRadius: 4,
      spreadRadius: 0,
    ),
  ];

  // 组件特定阴影
  static const List<BoxShadow> buttonShadow = elevation1;
  static const List<BoxShadow> buttonHoverShadow = elevation2;
  static const List<BoxShadow> buttonPressedShadow = elevation0;

  static const List<BoxShadow> cardShadow = elevation1;
  static const List<BoxShadow> cardHoverShadow = elevation2;

  static const List<BoxShadow> dialogShadow = elevation3;
  static const List<BoxShadow> bottomSheetShadow = elevation2;
  static const List<BoxShadow> drawerShadow = elevation4;

  static const List<BoxShadow> appBarShadow = elevation1;
  static const List<BoxShadow> tabBarShadow = elevation1;

  static const List<BoxShadow> floatingActionButtonShadow = elevation3;
  static const List<BoxShadow> floatingActionButtonHoverShadow = elevation4;

  // 特殊效果阴影
  static const List<BoxShadow> loadingShadow = elevation1;
  static const List<BoxShadow> skeletonShadow = elevation0;

  // 图像和媒体阴影
  static const List<BoxShadow> imageShadow = elevation1;
  static const List<BoxShadow> avatarShadow = elevation1;

  // 状态阴影
  static const List<BoxShadow> successShadow = [
    BoxShadow(
      color: Color(0x1A4CAF50),
      offset: Offset(0, 2),
      blurRadius: 6,
      spreadRadius: 1,
    ),
  ];

  static const List<BoxShadow> errorShadow = [
    BoxShadow(
      color: Color(0x1AEF4444),
      offset: Offset(0, 2),
      blurRadius: 6,
      spreadRadius: 1,
    ),
  ];

  static const List<BoxShadow> warningShadow = [
    BoxShadow(
      color: Color(0x1AFF9800),
      offset: Offset(0, 2),
      blurRadius: 6,
      spreadRadius: 1,
    ),
  ];

  static const List<BoxShadow> infoShadow = [
    BoxShadow(
      color: Color(0x1A2196F3),
      offset: Offset(0, 2),
      blurRadius: 6,
      spreadRadius: 1,
    ),
  ];

  // 暗色主题阴影
  static const List<BoxShadow> darkElevation1 = [
    BoxShadow(
      color: Color(0x3F000000),
      offset: Offset(0, 1),
      blurRadius: 3,
      spreadRadius: 1,
    ),
  ];

  static const List<BoxShadow> darkElevation2 = [
    BoxShadow(
      color: Color(0x3F000000),
      offset: Offset(0, 2),
      blurRadius: 6,
      spreadRadius: 2,
    ),
  ];

  static const List<BoxShadow> darkElevation3 = [
    BoxShadow(
      color: Color(0x3F000000),
      offset: Offset(0, 4),
      blurRadius: 8,
      spreadRadius: 3,
    ),
  ];

  // 获取适合当前主题的阴影
  static List<BoxShadow> getElevationShadow(int elevation, Brightness brightness) {
    final shadows = [
      elevation0,
      brightness == Brightness.light ? elevation1 : darkElevation1,
      brightness == Brightness.light ? elevation2 : darkElevation2,
      brightness == Brightness.light ? elevation3 : darkElevation3,
      elevation4,
      elevation5,
    ];
    
    return shadows[elevation.clamp(0, 5)];
  }

  // 动态阴影生成
  static List<BoxShadow> customShadow({
    required Color color,
    required Offset offset,
    required double blurRadius,
    double spreadRadius = 0,
  }) {
    return [
      BoxShadow(
        color: color,
        offset: offset,
        blurRadius: blurRadius,
        spreadRadius: spreadRadius,
      ),
    ];
  }
}